using System.Threading.Tasks;
using Abp.Configuration;
using Abp.Zero.Configuration;
using HiShing.TongDanGuanJia.Authorization.Accounts.Dto;
using HiShing.TongDanGuanJia.Authorization.Users;

namespace HiShing.TongDanGuanJia.Authorization.Accounts
{
    public class AccountAppService : TongDanGuanJiaAppServiceBase, IAccountAppService
    {
        // from: http://regexlib.com/REDetails.aspx?regexp_id=1923
        //public const string PasswordRegex = "(?=^.{8,}$)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\\s)[0-9a-zA-Z!@#$%^&*()]*$";

        private readonly UserRegistrationManager _userRegistrationManager;

        public AccountAppService(
            UserRegistrationManager userRegistrationManager)
        {
            _userRegistrationManager = userRegistrationManager;
        }

   
        public async Task<RegisterOutput> Register(RegisterInput input)
        {
            var user = await _userRegistrationManager.RegisterAsync(
                input.Name,
                input.UserName,
                input.Password
            );

           // var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueAsync<bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin);

            return new RegisterOutput
            {
                CanLogin = user.IsActive 
            };
        }
    }
}
